      SUBROUTINE SAGIM1(SY1,SY2,SY3,CIY)
C
      IMPLICIT REAL*8(A-H,O-Z)
C
      COMMON/CSAGIM/ AZIN(3,3),AZAX(3),AZCG(3),AZMS,AZYY(3,3),AZIAX(3,3)
     2              ,ZZAZ(3,3)
C
      COMMON/CONSTS/ PI,TWOPI,RADIAN
C
      COMMON/SAGMWK/ DELT,GAMGM(6),GMRHS,DI,DIGAM(6)
     1              ,DZML(6,6),YAZB(3)
C
      COMMON/SAGOUT/ AZ,AZD,B(3,3),B0(3,3),B0B(3,3),C(3,3),B0BC(3,3)
     1              ,YAZ(3),ZAZM(3)
C
      COMMON/SAPRPL/ GMBAZ,GMBAZD
C
      COMMON/SARSOT/ AZDD,SARHST(3),SARHSR(3)
C
      COMMON/ISAGIM/ IGMBL,NAZIM,NA1
C
      COMMON/ISAGRS/ IRAST,IARST(3),IRSCY(3)
C
      COMMON/RPOOL1/ DUMV1(80),YBCM(3),DUMV2(42)
C
      COMMON/VARBLS/ DEP(150),DER(150)
C
C
C
      DIMENSION CIY(3,3),DM1(3,3),DM2(3,3),DM3(3,3),DM4(3,3),DM5(3,3)
      DIMENSION V1(3),V2(3),V3(3),V4(3),V5(3),V6(3),V7(3),V8(3),V9(3)
      DIMENSION ANGM(3), ANGMD(3),ANGMDD(3)
C
      IF(IGMBL.EQ.0) RETURN
C
C     SAGIM1 IS CALLED FROM FNDALP TO INCLUDE SINGLE AXIS GIMBLE MASS
C     PROPERTIES IN SYSTEM INERTIA PROPERTIES
C
      IF(IRAST.EQ.0) GO TO 110
C
      DO 103 I=1,3
      ANGM(I)  = 0.0D0
      ANGMD(I) = 0.0D0
      ANGMDD(I)= 0.0D0
  103 CONTINUE
C
      CALL RASTSA(ANGM,ANGMD,ANGMDD)
C
      AZ  = ANGM(1)
      AZD = ANGMD(1)
      AZDD= ANGMDD(1)
C
      GO TO 120
C
  110 CONTINUE
C
      AZ=DEP(NAZIM)
      AZD=DEP(NA1)
C
  120 CONTINUE
C
      GMBAZ=AZ/RADIAN
      GMBAZD=AZD/RADIAN
C
      SAZ=DSIN(AZ)
      CAZ=DCOS(AZ)
C
      B(1,1)=CAZ
      B(2,2)=CAZ
      B(1,2)=-SAZ
      B(2,1)=SAZ
C
      CALL MPYMAT(B0,B,DM1,1,1,B0B,DM1)
      CALL MPYMAT(B0B,C,DM1,1,1,B0BC,DM1)
C
      CALL MATV(1,B0B,AZCG,V1)
      CALL MATV(2,B0B,AZAX,V7)
      CALL ADDV(AZAX,V1,YAZ)
C
      CALL MPYMAT(B0B,AZYY,B0B,2,2,DM4,DM3)
C
      DO 5 I=1,3
      DO 4 J=1,3
      ZZAZ(I,J)=AZIAX(I,J)
       DM5(I,J)= AZYY(I,J) + AZMS*AZCG(I)*V7(J)
      CIY(I,J)=CIY(I,J)         +DM3(I,J)
     1         +AZMS*YAZ(I)*YAZ(J)
    4 CONTINUE
      V3(I)=            AZMS*YAZ(I)
      YBCM(I)=YBCM(I)+V3(I)
      ZAZM(I)=            AZMS*AZCG(I)
    5 CONTINUE
C
      SY1=SY1+V3(1)
      SY2=SY2+V3(2)
      SY3=SY3+V3(3)
C
      DELT     =ZZAZ(1,1)+ZZAZ(2,2)
C
      CALL MATV(2,B0B,AZAX,YAZB)
      V4(1)=-(ZZAZ(1,3)+ZAZM(1)*YAZB(3))
      V4(2)=-(ZZAZ(2,3)+ZAZM(2)*YAZB(3))
      V4(3)=ZZAZ(1,1)+ZAZM(1)*YAZB(1)+ZZAZ(2,2)+ZAZM(2)*YAZB(2)
      CALL MATV(1,B0B,V4,V1)
C
      DO 10 I=1,3
      GAMGM(  I)=B0B(I,2)*ZAZM(1)-B0B(I,1)*ZAZM(2)
      I3=I+3
      GAMGM(  I3)=V1(I)
   10 CONTINUE
C
C
      DI=1.0D0/DELT
C
      DO 15 J=1,6
      DIGAM(  J)=DI     *GAMGM(  J)
   15 CONTINUE
C
      DO 20 I=1,6
      DO 20 J=1,6
      DZML(I,J)=GAMGM(  I)*DIGAM(  J)
   20 CONTINUE
C
C
      IF(IRAST.EQ.0)  RETURN
C
      V8(1)=-DM5(1,3)*AZDD
      V8(2)=-DM5(2,3)*AZDD
      V8(3)=(DM5(1,1)+DM5(2,2))*AZDD
C
      CALL MATV(1,B0B,V8,V1)
C
      V8(1)=-ZAZM(2)*AZDD
      V8(2)= ZAZM(1)*AZDD
      V8(3)=0.0D0
C
      CALL MATV(1,B0B,V8,V3)
C
      DO 140 I=1,3
      SARHST(I)=-V3(I)
      SARHSR(I)=-V1(I)
  140 CONTINUE
C
C
      RETURN
C
      END
